#!/usr/bin/env python3.0

import sys
import threading

print(sys.path)
sys.path.append("../")

import simpleplayer


class Playlist:
	def __init__(self, list):
		self.list = list
		self.i = 0
		self.fo = None
	def __iter__(self):
		return self
	def __next__(self):
		if self.fo!=None:
			self.fo.close()
		if (self.i==len(self.list)):
			raise StopIteration()

		fo = open(self.list[self.i], "rb")
		self.i += 1
		return fo

def main():
	playlist = Playlist(sys.argv[1:])
	player = simpleplayer.Player(playlist)

	while True:
		s = input("player> ")
		if s == "play":
			player.play()
		elif s == "next":
			player.next()
		elif s == "pause":
			player.pause()
		elif s == "unpause":
			player.unpause()
		elif s == "end":
			break
	player.close()


main()



